<?php

class model_newagk_qbank extends gdl_components_basemodel
{

    public function primarykey() {
        return 'id';
    }

    public function tableName() {
        return 'agk_qbank';

    }
	public function getInfo($id){
		$result = $this->selectOne(['isdelete'=>0,'id'=>$id],'*');
		return $result;
	}
	
	public function getQbankList($parentid=-1)
	{
		$sql_where = 'isdelete=0';
		if($parentid>=0) $sql_where .= ' and parentid='.$parentid;
		/*
        $child_platform = getChildAdminRegByPlaformId($this->platform);
		if(!empty($child_platform)){
			 $sql_where .= " and admin_reg in('".implode("','",$parentid."')";
		}
		*/
		$result = $this->select(['admin_reg'=>['in',$child_platform],'isdelete'=>0])->where('isdelete=0')->items;


	
		return $result;
	}
	
	public function getListByArgName($platform){
		//$this->getListByArg('platformId='.$platform);
		$qbank_name = $this->getListByArg('isdelete=0','id,name');
		$data = [];
		foreach($qbank_name as $v){
			$data[$v['id']] = $v['name'];
		}
		return $data;
	}
	
	public function getListByArgNamefield($reg,$field='*'){
		//$this->getListByArg('platformId='.$reg);
		$qbank_name = $this->getListByArg('isdelete=0',$field);
		$data = [];
		foreach($qbank_name as $v){
			$data[$v['id']] = $v;
		}
		return $data;
	}
	
	public function getListByArg($arg='',$field='*'){
        if ($arg=='')return false;
        $arg = $this->select($arg,$field)->items;
        return $arg;
    }

}
